home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7094 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  40 lines

  1. Path: newsfeeds.ans.net!butch!news
  2. From: Rick Richert <richert>
  3. Newsgroups: comp.lang.c++
  4. Subject: Global Objects with argc & argv
  5. Date: 20 Feb 1996 19:07:21 GMT
  6. Organization: Org. 81-20
  7. Message-ID: <4gd659$95@butch.lmsc.lockheed.com>
  8. NNTP-Posting-Host: sgi564.msd.lmsc.lockheed.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1N (X11; I; IRIX 5.3 IP22)
  13. X-URL: news:comp.lang.c++
  14.  
  15. I have some global objects defined outside the main routine and I would
  16. like to pass the argc and argv values to their constructors.  For example,
  17.  
  18.  
  19. SomeClass obj( argc, argv);
  20.  
  21. int main( int argc, char **argv) {
  22.  
  23.    blah, blah, blah
  24.  
  25. }
  26.  
  27. Unfortunately, the compiler tells me that argc and argv are not defined or else
  28. not available for obj.
  29.  
  30. Currently, I get around this problem by creating the global obj and then inside
  31. of main, I initialize obj via a method that takes argc and argv.  
  32.  
  33. I would prefer to pass the arg vars to the constructor.  Does anyone know how I
  34. can pass the arg vars without being inside of main?
  35.  
  36. -- 
  37.         Rick Richert 
  38.         richert@lmsc.lockheed.com
  39.  
  40.